
<script setup lang="ts">
    
import { reactive } from 'vue'
import { taskAllListAPI } from "@/api/task";
import { Toast } from 'vant';
import { useRoute, useRouter } from 'vue-router';
import CompanySource from '../task/components/CompanySource.vue'
import CompanyTask from '../task/components/CompanyTask.vue'

    const route = useRoute()
    const router = useRouter()
    const companyId = route.params.id    
    const state = reactive({
        item: '',
        taskList: [],
        loading: false
    })
   
    // 获取任务列表
    const getTaskAllList = async() => {
        const res = await taskAllListAPI({    
            company_id: companyId   
        })
        if (res) {
            state.taskList = res.records
            state.item = res.records[0]
            state.loading = false
        }else{
            Toast('获取列表失败')
        }
    }
    getTaskAllList()
    // 点击返回 关闭弹窗
    const onClickLeft = () => router.back()
</script>

<template>
    <van-nav-bar
        title="任务来源"
        left-arrow
        @click-left="onClickLeft"
    />
    <CompanySource :item="state.item" />
    <CompanyTask :taskList="state.taskList" />
</template>

<style scoped>

</style>